2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #ifndef __JUCER_COMPONENTLAYOUT_JUCEHEADER__
27 #define __JUCER_COMPONENTLAYOUT_JUCEHEADER__
30 #include "components/jucer_ComponentTypeHandler.h"
34 //==============================================================================
36 Manages the set of sub-components for a JucerDocument.
42 //==============================================================================
46 //==============================================================================
49 int getNumComponents() const throw() { return components
.size(); }
50 Component
* getComponent (const int index
) const throw() { return components
[index
]; }
51 int indexOfComponent (Component
* const comp
) const throw() { return components
.indexOf (comp
); }
52 bool containsComponent (Component
* const comp
) const throw() { return components
.contains (comp
); }
54 //==============================================================================
55 void clearComponents();
56 void removeComponent (Component
* comp
, const bool undoable
);
58 Component
* addNewComponent (ComponentTypeHandler
* const type
, int x
, int y
);
59 Component
* addComponentFromXml (const XmlElement
& xml
, const bool undoable
);
61 Component
* findComponentWithId (const int64 componentId
) const;
63 //==============================================================================
64 void componentToFront (Component
* comp
, const bool undoable
);
65 void componentToBack (Component
* comp
, const bool undoable
);
67 void setComponentPosition (Component
* comp
, const RelativePositionedRectangle
& newPos
, const bool undoable
);
68 void updateStoredComponentPosition (Component
* comp
, const bool undoable
);
70 //==============================================================================
71 Component
* getComponentRelativePosTarget (Component
* comp
, int whichDimension
) const;
72 void setComponentRelativeTarget (Component
* comp
, int whichDimension
, Component
* compToBeRelativeTo
);
73 // checks recursively whether the comp depends on the given comp for its position
74 bool dependsOnComponentForRelativePos (Component
* comp
, Component
* possibleDependee
) const;
76 PopupMenu
getRelativeTargetMenu (Component
* comp
, int whichDimension
) const;
77 void processRelativeTargetMenuResult (Component
* comp
, int whichDimension
, int menuResultID
);
79 //==============================================================================
80 void setComponentMemberVariableName (Component
* comp
, const String
& newName
);
81 const String
getComponentMemberVariableName (Component
* comp
) const;
83 //==============================================================================
84 void setComponentVirtualClassName (Component
* comp
, const String
& newName
);
85 const String
getComponentVirtualClassName (Component
* comp
) const;
87 //==============================================================================
88 SelectedItemSet
<Component
*>& getSelectedSet() { return selected
; }
90 static const char* const clipboardXmlTag
;
91 void copySelectedToClipboard();
93 void deleteSelected();
96 void selectedToFront();
97 void selectedToBack();
100 void dragSelectedComps (int dxFromDragStart
, int dyFromDragStart
, const bool allowSnap
= true);
103 void moveSelectedComps (int dx
, int dy
, bool snap
);
104 void stretchSelectedComps (int dw
, int dh
, bool allowSnap
);
106 void bringLostItemsBackOnScreen (int width
, int height
);
108 //==============================================================================
109 void setDocument (JucerDocument
* const document_
) { document
= document_
; }
110 JucerDocument
* getDocument() const throw() { return document
; }
112 //==============================================================================
113 void addToXml (XmlElement
& xml
) const;
115 void fillInGeneratedCode (GeneratedCode
& code
) const;
117 void perform (UndoableAction
* action
, const String
& actionName
);
120 JucerDocument
* document
;
121 OwnedArray
<Component
> components
;
122 SelectedItemSet
<Component
*> selected
;
125 const String
getUnusedMemberName (String nameRoot
, Component
* comp
) const;
127 friend class FrontBackCompAction
;
128 friend class DeleteCompAction
;
129 void moveComponentZOrder (int oldIndex
, int newIndex
);
133 #endif // __JUCER_COMPONENTLAYOUT_JUCEHEADER__